<?php  
include 'codeBack.config.php';
include "connectMysql.php";
include "empty.php";
include 'header.php';
$date = $_POST["date"];
$morning = $_POST["morning"];
$afternoon = $_POST["afternoon"];
$evening = $_POST["evening"];
$other = $_POST["other"];
$userid = $_POST["user_id"];
$token = $_POST["token"];
if(!$date || !$morning || !$afternoon || !$evening || !$other || !$userid || !$token){
	exit();
}
$ac_user_sql = "SELECT * from ac_user WHERE user_id='$userid' AND token='$token'";
$ac_user_result = $mysqli->query($ac_user_sql);
$ac_user_row = mysqli_fetch_object($ac_user_result);
if($ac_user_row->token == $token && $ac_user_row->user_id == $userid){
	// 查找成功
	$ac_user_info_sql = "INSERT INTO ac_user_info (date,morning,afternoon,evening,other,user_id) VALUES('$date','$morning','$afternoon','$evening','$other','$userid')";
	$ac_user_info_result = $mysqli->query($ac_user_info_sql);
	if($ac_user_info_result){
		// 插入成功
		$data = [
			"code"=>$CodeBack["ADDINFO_SUCCESS_CODE"],
			"user_id"=>$ac_user_row->user_id,
			"id"=>$mysqli->insert_id,
			"message"=>"添加成功",
		];
		echo json_encode($data);
	}else {
		$data = [
			"code"=>$CodeBack["ADDINFO_FAILED_CODE"],
			"message"=>"添加失败，请稍后再试",
		];
		echo json_encode($data);
	}
}